package com.wuseguang.springcloud.mina;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;

public class ByteArrayDecoder extends CumulativeProtocolDecoder {
    @Override
    protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput protocolDecoderOutput) throws Exception {

        byte[] byten = new byte[in.limit()];
        in.get(byten, in.position(), in.limit());
        String temp = HexUtil.binaryToHexString(byten);
        temp = HexUtil.hexStringToString(temp);
        protocolDecoderOutput.write(temp);
        return false;
    }
}
